package com.http.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.http.pojo.Depts;
import com.http.pojo.Mybooks;
import com.http.service.DeptsService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.annotation.Resource;
import java.util.List;
@Controller
public class Action {
    //注入service的实例
    @Resource(name="DeptsService")
    private DeptsService deptsService;
    @RequestMapping("/day")
    public  String  Select(Model model,
                           @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum){
         //PageHelper.startPage(int PageNum,int PageSize):用来设置页面的位置和展示的数据条目数
        PageHelper.startPage(pageNum,5);
        List<Depts> list= this.deptsService.getSelect();
        PageInfo<Depts> pageInfo = new PageInfo<Depts>(list);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("userlist",list);
        return "day";
    }
    @RequestMapping("/info")
    public  String  Selecqt(Model model,
                           @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum){
        PageHelper.startPage(pageNum,7);
        List<Mybooks> list= this.deptsService.findBook();
        PageInfo<Mybooks> pageInfo = new PageInfo<Mybooks>(list);
        model.addAttribute("pageInfo",pageInfo);
        return "day";
    }

}
